Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@xylabs/assert

Package Overview
Dependencies
Maintainers
5
Versions
230
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xylabs/assert

Base functionality used throughout XY Labs TypeScript/JavaScript libraries

  • 3.6.12
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.5K
increased by49.92%
Maintainers
5
Weekly downloads
 
Created
Source

logo

@xylabs/assert

npm-badge npm-downloads-badge jsdelivr-badge npm-license-badge socket-badge

XY Labs generalized Javascript library

Table of Contents

Description

Common Javascript code that is used throughout XYO projects that use React.

Install

Using npm:

npm i --save @xylabs/assert

Using yarn:

yarn add @xylabs/assert

Usage

The assertEx function is a utility function for simple null/undefined checks for variables. It evaluates an expression for truthiness and throws an error if the expression is false.

Here are some examples of how to use assertEx in different scenarios:

  • Basic usage:

    import { assertEx } from '@xylabs/assert';
    
    const value = getValue(); // This is a function that may return null or undefined
    assertEx(value); // Throws an AssertExError with a default message if value is null or undefined
    
  • Using with a custom error message:

    import { assertEx } from '@xylabs/assert';
    
    const value = getValue(); // This function may return null or undefined
    assertEx(value, () => 'Dynamic error message based on some conditions'); // Throws an AssertExError with a dynamic message if value is null or undefined
    

Maintainers

License

See the LICENSE file for license details

Credits

Made with 🔥and ❄️ by XY Labs

Keywords

FAQs

Package last updated on 05 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc